import 'package:permission_handler/permission_handler.dart';

export 'package:permission_handler/permission_handler.dart' show Permission, PermissionStatus;

class PermissionUtils {
  /// 工厂模式
  factory PermissionUtils() => _getInstance();

  /// 单例
  static PermissionUtils get instance => _getInstance();
  static PermissionUtils? _instance;

  PermissionUtils._internal();

  static PermissionUtils _getInstance() => _instance ??= PermissionUtils._internal();

  /// 打开app系统设置
  Future<bool> get forwardAppSettings => openAppSettings();

  /// 统一集合request
  Future<Map<Permission, PermissionStatus>?> request(List<Permission> permissionList) async {
    if (permissionList.isEmpty) {
      return null;
    }
    return await permissionList.request();
  }
}
